using System;

namespace SharpMud.MudLib.SAMPLE.Commands.Metadata
{
	/// <summary>
	/// Outlines criteria that a character must match to be able to execute a command.
	/// Execution requirements are not to be confused with visibility requirements.
	/// </summary>
	public abstract class ExecutionRequirementAttribute
	{	
		private Entities.Filtration.ICharacterFilter _Filter;
		private string								__ExecutionFailureExplanation;

		protected ExecutionRequirementAttribute()
		{
		}

		public ExecutionRequirementAttribute(Entities.Filtration.ICharacterFilter filter,string executionFailureExplanation)
		{
			_Filter = filter;
			__ExecutionFailureExplanation = executionFailureExplanation;
		}

		public ExecutionRequirementAttribute(string executionFailureExplanation, Entities.Filtration.ICharacterFilter filter)
		{
			_Filter = filter;
			__ExecutionFailureExplanation = executionFailureExplanation;
		}

		protected virtual bool _AllowsExecutionFor(Entities.ICharacter character)
		{
			return _Filter.DoesCharacterPass(character);
		}

		protected virtual string _ExecutionFailureExplanation
		{
			get
			{
				return __ExecutionFailureExplanation;
			}
		}

		public bool AllowsExecutionFor(Entities.ICharacter character)
		{
			return _AllowsExecutionFor(character);
		}

		public string ExecutionFailureExplanation
		{
			get
			{
				return _ExecutionFailureExplanation;
			}
		}
	}
}
